//#define ARM7
//#include <nds.h>
//#undef ARM9
//#define ARM7
//#include <nds.h>
#include <nds/system.h>
#include <nds/arm7/serial.h>
#include <nds/arm7/audio.h>
//#undef ARM7
#include <nds/timers.h>
#include <nds/dma.h>
#include <nds/interrupts.h>

#undef ARM7
#define ARM9
#include <nds/ipc.h>
#include <nds/memory.h>
#include <nds/arm9/video.h>
//#include <nds/arm9/cache.h>

#ifndef DS_STATION
#ifndef TWL
#error "DS_STATION and NZONE/TWL aren't defined, define one."
#endif
#endif

#ifdef DS_STATION
#define NDSHEADER ((tNDSHeader *)0x027FFE00)
#endif
#ifdef TWL
#define NDSHEADER ((tNDSHeader *)0x02FFFE00)
#endif

#ifdef DS_STATION
#define BOOTFLAG *((vu8*)0x027FFDFF)
#endif
#ifdef TWL
#define BOOTFLAG *((vu8*)0x02FFFDFF)
#endif

typedef unsigned int size_t;
void* memset(void* buffer, int val, size_t len);
void* memcpy(void* a, const void* b, size_t len);
void* memcpy16(void* a, const void* b, size_t len);
void memset_addrs(void* start, void* end);
void memcpy_addrs(void* start, void* end, void* dst);
void memcpy16_addrs(void* start, void* end, void* dst);

void inline memcpy_arm9(void* a, void* b, size_t len);
void memset_arm7(void* buffer, int val, size_t len);
void memcpy_arm7(void* a, void* b, size_t len);
void memset_addrs_arm7(void* start, void* end);

void __attribute__ ((long_call)) DC_FlushAll();
void DC_InvalidateAll();
void IC_InvalidateAll();
void DC_FlushRange(void* addr, u32 length);

